import time
from data001.Base.Base import Base
from selenium.webdriver.common.by import By

class Page(Base):
    login_loc = (By.CSS_SELECTOR,'.top-right > ul:nth-child(1) > li:nth-child(1) > a:nth-child(1)')
    # 点击登录
    def login(self):
        self.click(self.login_loc)
    # 输入账号
    name_loc = (By.XPATH,'//input[@name="username" and @class="regi-input"]')
    def username(self,username):
        self.send_keys(self.name_loc,username)
    # 输入密码
    password_loc = (By.XPATH,'//input[@type="password" or @name="password"]')
    def password(self,password):
        self.send_keys(self.password_loc,password)
    # 点击登录按钮
    click_button_loc = (By.XPATH,'//a[@class="finish-btn"]')
    def click_button(self):
        self.click(self.click_button_loc)
    # 断言登录成功
    dy1_loc = (By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a')
    def dy1(self):
        return self.text(self.dy1_loc)

    def test_a3mall_login(self,username,password):
        self.open_url('http://10.59.9.12:7001/')
        self.login()
        self.username(username)
        self.implicitly_wait()
        self.password(password)
        time.sleep(7)
        self.click_button()
        time.sleep(2)
        self.dy1()
        time.sleep(5)
